package com.niji.littly_donkey_android.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.makeramen.roundedimageview.RoundedImageView;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.bean.BankCard;
import com.niji.littly_donkey_android.bean.Follow;
import com.niji.littly_donkey_android.util.BitMapUtil;
import com.niji.littly_donkey_android.util.CirclePhotoUtil;

import java.util.ArrayList;

public class BankCardAdapter extends ArrayAdapter<BankCard> {


    private static final String TAG = "BankCardAdapter";

    public BankCardAdapter(Context context, ArrayList<BankCard> members)
    {
        super(context,0, members);
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        BankCard bankCard = getItem(position);

        if(convertView == null)
        {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_bank_card, parent, false);
        }

        TextView bankCardId = convertView.findViewById(R.id.bank_card_id);
        TextView bankCardName = convertView.findViewById(R.id.bank_card_name);
        TextView bankCardNumber = convertView.findViewById(R.id.bank_card_number);
        RelativeLayout bankCardBj = convertView.findViewById(R.id.bank_card_bj);
        ImageView bankCardLogo = convertView.findViewById(R.id.bank_card_logo);
        RelativeLayout bankCardDefault = convertView.findViewById(R.id.bank_card_default);
        bankCardId.setText("" + bankCard.getId());
        bankCardName.setText(bankCard.getName());
        bankCardNumber.setText(bankCard.getNumber());
        if (bankCard.getDefault()){
            bankCardDefault.setVisibility(View.VISIBLE);
        }
        if(bankCard.getName().equals("工商银行")){
            bankCardBj.setBackground(convertView.getResources().getDrawable(R.drawable.gongshang));
            bankCardLogo.setImageDrawable(convertView.getResources().getDrawable(R.mipmap.gongshanglogo));

        }else if(bankCard.getName().equals("建设银行")){
            bankCardBj.setBackground(convertView.getResources().getDrawable(R.drawable.jianghang));
            bankCardLogo.setImageDrawable(convertView.getResources().getDrawable(R.mipmap.jiehanglogo));
        }else if(bankCard.getName().equals("招商银行")){
            bankCardBj.setBackground(convertView.getResources().getDrawable(R.drawable.gongshang));
            bankCardLogo.setImageDrawable(convertView.getResources().getDrawable(R.mipmap.zhaohanglogo));
        }else if(bankCard.getName().equals("中国农业银行")){
            bankCardBj.setBackground(convertView.getResources().getDrawable(R.drawable.nonghang));
            bankCardLogo.setImageDrawable(convertView.getResources().getDrawable(R.mipmap.nonghanglogo));
        }

        return convertView;
    }

}



